/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.SQLException;
import java.util.ArrayList;
import modelo.AreaCientifica;
import util.Conexao;
import util.Dao;

/**
 *
 * @author bruno
 */
public class AreaCientificaDao extends Dao<AreaCientifica> {

    public AreaCientificaDao() {
        super(new Conexao("Aurea", "sa", "sa", Conexao.sqlServerDriver));
    }

    @Override
    protected AreaCientifica novoModelo() {
        return new AreaCientifica();
    }

    @Override
    public boolean gravar(AreaCientifica modelo) {
        return gravarModelo("INSERT INTO tbAreaCientifica(designacao,descricao)"
                + "VALUES(?,?)", modelo);
    }

    @Override
    protected void definirParametrosGravar() throws SQLException {
        conexao.getStatement().setString(1, modelo.getDesignacao());
        conexao.getStatement().setString(2, modelo.getDescricao());
    }

    @Override
    public AreaCientifica ler(int id) {
        return lerModelo("SELECT * FROM tbAreaCientifica WHERE idAreaCientifica=?", id);
    }

    @Override
    protected void definirParametrosLer() throws SQLException {
        modelo.setDesignacao(conexao.getResultSet().getString("designacao"));
        modelo.setDescricao(conexao.getResultSet().getString("descricao"));
    }

    @Override
    public ArrayList<AreaCientifica> lerTodos() {
        return lerTodos("SELECT * FROM tbAreaCientifica");
    }
    
    
}
